#!/bin/sh
echo "======install Redis==========="
v_soft_path="/usr/local/atwork/"

v_install_store_path="/tmp/atwork/"

v_install_file="redis-2.8.17.tar.gz"

v_install_dir="redis-2.8.17"

#检测软件安装目录是否存在
f_soft_path_check(){
 if [ ! -d "$v_soft_path" ]; then
   mdkir -p  "$v_soft_path"
 fi
}

#检测安装文件是否存在
f_install_file_exists(){
 if [ ! -f "${v_install_store_path}${v_install_file}" ]; then
   echo "install file not exists:${v_install_store_path}${v_install_file}"
   exit 1
 fi
}

#安装redis
f_install_redis(){
  tar -zxvf ${v_install_store_path}${v_install_file} -C $v_soft_path
}

#编译redis
f_make_redis(){
  cd ${v_soft_path}${v_install_dir}
  make MALLOC=libc
  make install
}

f_soft_path_check

f_install_file_exists

f_install_redis

f_make_redis
echo "=======install Redis OK========"
